package com.ctim.dao.user;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * User: lb on 2016/9/6.
 * Date:2016-09-06-18:18
 * desc：
 */

@Repository
public class ResourceRoleDao {
    @Autowired
    @Qualifier("sqlSession")
    private SqlSessionTemplate sqlSession;

    public void insertResourceRole(Integer roleId, String[] resources) {
        Map<String, Object> map = new HashMap();
        map.put("roleId", roleId);
        map.put("resources", resources);
        sqlSession.insert("dta.role.insertResourceRole",map);
    }

    public void updateResourceRole(Integer roleId, String[] resources){
        Map<String, Object> map = new HashMap();
        map.put("roleId", roleId);
        map.put("resources", resources);
        sqlSession.delete("dta.role.deleteResourceRole", roleId);
        this.insertResourceRole(roleId, resources);
    }

}
